"""
topMovies.py

Prints top 10 movies, by ratings.
"""

import sys

# Import the IMDbPY package.
try:
    import imdb
except ImportError:
    print 'You need to install the IMDbPY package!'
    sys.exit(1)

def unic(string):
    try:
        print string
    except UnicodeEncodeError:
        print 'bad movie title'


i = imdb.IMDb()

top250 = i.get_top250_movies()


print ''
print 'top 250 movies'
print 'rating\tvotes\ttitle'
for movie in top250:
    movie.get('title')
    unic('%s\t%s\t%s' % (movie.get('rating'), movie.get('votes'),
                                movie['long imdb title']))
